home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_03 / kamradt / empty.h < prev    next >
C/C++ Source or Header  |  1994-02-07  |  692b  |  40 lines

  1. class AttributeList {
  2. private:
  3.    struct AttributeListImp {
  4.      int *list;
  5.      unsigned count;
  6.      AttributeListImp(int *
  7.        data, unsigned size) 
  8.      { 
  9.        list = new int[size];
  10.        memcpy(list,data,
  11.          sizeof(int)*size);
  12.        count = 1;
  13.     }
  14.    } *ptr;
  15. public:
  16.    AttributeList() 
  17.    { 
  18. // Empty list special case:
  19.      ptr = NULL; 
  20.    }    
  21.    AttributeList(int *data, 
  22.      unsigned size) 
  23.    { 
  24.      ptr = new 
  25.        AttributeListImp(data,
  26.          size);
  27.    }
  28.    AttributeList(const 
  29.      AttributeList &a)
  30.    {
  31. // Now we have to check 
  32. // for null:
  33.      ptr = a.ptr;
  34.      if(ptr) ptr->count++;
  35.    }
  36.  
  37. ...             
  38.  
  39. };
  40.